<include file="public@header"/>
<link href="/themes/admin_simpleboot3/public/assets/themes/flatadmin/modal.css" rel="stylesheet" type="text/css">
<style>
    .extend .layui-input {width:198px;display: inline-block;margin: 0 5px 7px 0;}
    .addExtend,.removeExtend{font-size: 14px;}
    .longlat input{display: inline-block;}
    
</style>
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}">
        <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
        <input class="layui-input" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
               style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
             onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>
</head>
<body>
    <div class="layui-fluid js-check-wrap">
        <ul class="nav nav-tabs">
            <li><a href="{:url('AdminBranch/index', array('b_r_id'=>input(b_r_id) ))}">{:lang('PORTAL_ADMINBRANCH_INDEX')}</a></li>
            <li><a href="{:url('AdminBranch/add',array('b_r_id'=>$post['b_r_id']))}" target="_self">{:lang('PORTAL_ADMINBRANCH_ADD')}</a></li>
            <li class="active"><a href="#A" data-toggle="tab">{:lang('PORTAL_ADMINBRANCH_EDIT')}</a></li>
            <li><a href="#B" data-toggle="tab">地图坐标信息</a></li>
        </ul>

        <div class="row margin-top-20">
    
            <div class="col-md-12">
                <form class="js-ajax-form" action="{:url('AdminBranch/editPost')}" method="post">
                    <div class="tab-content">
                        <div class="tab-pane active" id="A">
                            <div class="row">
                                <div class="col-md-9">
                                    <table class="table table-bordered">
                                        <tr>
                                            <th>{:lang('BRANCH_NAME')}<span class="form-required">*</span></th>
                                            <td>
                                                <input class="layui-input" id="branch_name" type="text" name="post[branch_name]" value="{$post.branch_name}"  placeholder="请输入{:lang('BRANCH_NAME')}"/>
                                                
                                            </td>
                                        </tr>
                                        <tr>
                                            <th width="90">{:lang('B_NAME')}</th>
                                            <td>
                                                <select name="post[b_r_id]" id="region" class="layui-input" >
                                                    <option value="0">{:lang('SELECT_PLEASE')}</option>
                                                    {$branch_region_list}
                                                </select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th>{:lang('ADDRESS')}</th>
                                            <td>
                                                <input class="layui-input" id="address" type="text" name="post[address]" value="{$post.address}" placeholder="请输入{:lang('ADDRESS')}"/>
                                                <p class="layui-word-aux">用于联系我们页面地图上显示</p>
                                            </td>
                                        </tr>
                                        <tr class="is_open">
                                            <th>是否显示</th>
                                            <td>
                                                <p class="layui-word-aux" style="display:inline-block;">是否需要在联系我们页面显示</p>
                                                <div class="checkbox" style="margin:0;display:inline-block;">
                                                    <label><input type="radio" name="post[is_open]" value="1" onclick="radioClicked(1)" <eq name="post.is_open" value="1">checked</eq> />是</label>
                                                    <label><input type="radio" name="post[is_open]" value="0" onclick="radioClicked(0)" <eq name="post.is_open" value="0">checked</eq> />否</label>
                                                </div>
                                                <div class="longlat">
                                                    <input class="layui-input" id="text_" type="text" placeholder="请输入要查询的地址（北京）" style="width:220px;display:inline-block;"/>
                                                    <input class="btn btn-default" type="button" value="查 询" onclick="searchByStationName();"/>
                                                    &nbsp;&nbsp;
                                                    经度：<input class="layui-input" name="post[longitude]" type="text" id="jingdu" style="min-width:120px;width:120px;" readonly="" value="{$post[longitude]}" />
                                                    纬度：<input class="layui-input" name="post[latitude]" type="text" id="weidu" style="min-width:120px;width:120px;" readonly="" value="{$post[latitude]}" />
                                                    <p class="layui-word-aux" style="display:inline-block;">请输入要查询的地址，启用滚轮放大地图然后将标注拖动到具体位置可显示其经纬度</p>
                                                    <div id="container"
                                                          style="
                                                            width: 100%;
                                                            height: 400px;
                                                            border: 1px solid gray;
                                                            overflow:hidden;">
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th>关键词</th>
                                            <td>
                                                <input class="layui-input" id="keywords" type="text" name="post[keywords]" value="{$post.keywords}" placeholder="请输入关键字">
                                                <p class="layui-word-aux">多关键词之间用空格或者英文逗号隔开</p>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th>摘要</th>
                                            <td>
                                                <textarea class="layui-input" id="excerpt" name="post[excerpt]" style="height: 50px;" placeholder="请填写摘要">{$post.excerpt}</textarea>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th>联系我们内容</th>
                                            <td>
                                                <script type="text/plain" id="content" name="post[content]">{$post.content}</script>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th>详细内容</th>
                                            <td>
                                                <script type="text/plain" id="content2" name="post[detail_content]">{$post.detail_content}</script>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th>扩展信息</th>
                                            <td>
                                                <foreach name="post['extend']['info']" item="item">
                                                    <div class="extend">
                                                        <input class="layui-input" type="text" name="extend_name[]" placeholder="请输入名称" value="{$item.name}"><input class="layui-input" type="text" name="extend_val[]"  placeholder="请输入值" value="{$item.val}"><a href="javascript:;" class="removeExtend">[-]</a>
                                                    </div>
                                                </foreach>
                                                <div class="extend">
                                                    <input class="layui-input" ype="text" name="extend_name[]" placeholder="请输入名称"><input class="layui-input" type="text" name="extend_val[]"  placeholder="请输入值"><a href="javascript:;" class="addExtend">[+]</a>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th>视频</th>
                                            <td>
                                                <ul id="file_video" class="pic-list list-unstyled form-inline">
                                                    <input id="file-video" type="hidden" name="post[file_url]" value="{$post.file_url}">
                                                    <input class="layui-input" id="file-video-name" type="text" name="post[file_name]" style="width: 400px;" title="文件名称" value="{$post.file_name}" readonly>
                                                    <a href="javascript:uploadOne('视频上传','#file-video','video');">选择文件</a>
                                                    <a href="javascript:(function(){$('#file-video').val('');$('#file-video-name').val('');})();">移除</a>
                                                </ul>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th>相册</th>
                                            <td>
                                                <ul id="photos" class="pic-list list-unstyled form-inline">
                                                    <notempty name="post.more.photos">
                                                        <foreach name="post.more.photos" item="vo">
                                                            <php>$img_url=cmf_get_image_preview_url($vo['url']);</php>
                                                            <li id="saved-image{$key}">
                                                                <input id="photo-{$key}" type="hidden" name="photo_urls[]"
                                                                       value="{$vo.url}">
                                                                <input class="layui-input" id="photo-{$key}-name" type="text"
                                                                       name="photo_names[]"
                                                                       value="{$vo.name|default=''}" style="width: 200px;" title="图片名称">
                                                                <img id="photo-{$key}-preview"
                                                                     src="{:cmf_get_image_preview_url($vo['url'])}"
                                                                     style="height:36px;width: 36px;"
                                                                     onclick="parent.imagePreviewDialog(this.src);">
                                                                <a href="javascript:uploadOneImage('图片上传','#photo-{$key}');">替换</a>
                                                                <a href="javascript:(function(){$('#saved-image{$key}').remove();})();">移除</a>
                                                            </li>
                                                        </foreach>
                                                    </notempty>
                                                </ul>
                                                <a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"
                                                   class="btn btn-default btn-sm">选择图片</a>
                                                <p class="layui-word-aux">推荐尺寸 620px * 470px</p>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                                <div class="col-md-3">
                                    <table class="table table-bordered">
                                        <tr>
                                            <th><b>缩略图</b></th>
                                        </tr>
                                        <tr>
                                            <td>
                                                <div style="text-align: center;" class="upload-image">
                                                    <input type="hidden" name="post[more][thumbnail]" id="thumbnail"
                                                           value="{$post.more.thumbnail|default=''}">
                                                    <a href="javascript:uploadOneImage('图片上传','#thumbnail');">
                                                        <if condition="empty($post.more.thumbnail)">
                                                            <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                                                 id="thumbnail-preview"
                                                                 width="135" style="cursor: pointer"/>
                                                            <else/>
                                                            <img src="{:cmf_get_image_preview_url($post.more.thumbnail)}"
                                                                 id="thumbnail-preview"
                                                                 width="135" style="cursor: pointer"/>
                                                        </if>
                                                    </a>
                                                    <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
                                                    <p class="layui-word-aux">推荐尺寸 326px * 242px</p>
                                                </div>
                                            </td>
                                        </tr>

                                        <tr>
                                            <th><b>发布时间</b></th>
                                        </tr>
                                        <tr>
                                            <td>
                                                <input class="layui-input js-layui-datetime" type="text" name="post[published_time]"
                                                       value="{:date('Y-m-d H:i:s',time())}">
                                            </td>
                                        </tr>

                                        <tr>
                                            <th><b>状态</b></th>
                                            <php>
                                                $is_top_yes      = $post['is_top']==1?"checked":"";
                                                $recommended_yes = $post['recommended']==1?"checked":"";
                                                $is_default_yes  = $post['is_default']==1?"checked":"";
                                                $is_show_yes     = $post['is_show']==1?"checked":"";
                                            </php>
                                        </tr>
                                        <tr>
                                            <td>
                                                <div class="checkbox">
                                                    <label><input type="checkbox" name="post[is_top]" value="1" {$is_top_yes}>置顶</label>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <div class="checkbox">
                                                    <label><input type="checkbox" name="post[recommended]" value="1" {$recommended_yes}>推荐</label>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <div class="checkbox">
                                                    <label><input type="checkbox" name="post[is_default]" value="1" {$is_default_yes}>默认</label>
                                                </div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <div class="checkbox">
                                                    <label><input type="checkbox" name="post[is_show]" value="1" {$is_show_yes}>显示</label>
                                                </div>
                                            </td>
                                        </tr>
                                        
                                        <tr>
                                            <th>文章模板</th>
                                        </tr>
                                        <tr>
                                            <td>
                                                <select class="layui-input" name="post[more][template]" id="more-template-select">
                                                    <!-- <option value="">请选择模板</option> -->
                                                    <foreach name="article_theme_files" item="vo">
                                                        <php>$value=preg_replace('/^portal\//','',$vo['file']);</php>
                                                        <option value="{$value}">{$vo.name} {$vo.file}.html</option>
                                                    </foreach>
                                                </select>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane" id="B">
                            <div class="row">
                                <div class="col-md-12" style="padding:0;">
                                    <table class="table table-bordered">
                                        <tr>
                                            <th width="80">地图坐标点</th>
                                            <td>
                                                <div class="coordinate">
                                                    <button onclick="return false;" class="btn add_coordinate">添加坐标点</button>
                                                    <button style="margin:0;" onclick="return false;" class="layui-btn layui-btn-primary remove_coordinate">删除坐标点</button>
                                                    &nbsp;
                                                    坐标名称：<input type="text" class="layui-input w200 coordinate_name" name="post[more][dian_name][name]">
                                                    <button onclick="return false;" class="btn add_coordinate_name">添加坐标名</button>
                                                    <button style="margin:0;" onclick="return false;" class="layui-btn layui-btn-primary remove_coordinate_name">删除坐标名</button>
                                                    <p class="layui-word-aux">说明：点击下方坐标点或坐标名后可进行相应移动，再次点击停止移动</p>
                                                    <!-- <img src="{:cmf_get_image_url($region['b_thumb'])}" alt=""> -->
                                                    <div class="map" style="width:1400px;">
                                                        <div class="main">
                                                            <div style="position:relative;">
                                                                <div class="dian"></div>
                                                                <div class="name">{$post[more][dian_name][name]}</div>
                                                            </div>
                                                        </div>
                                                        <img class="bimg" src="{:cmf_get_image_url($region['b_thumb'])}" alt="">
                                                        <!-- <div class="bg" style="background:url({:cmf_get_image_url($region['b_thumb'])}) no-repeat center center;"></div> -->
                                                    </div>
                                                    <input type="hidden" value="{$post[more][dian][top]}" class="coordinate_top" name="post[more][dian][top]">
                                                    <input type="hidden" value="{$post[more][dian][left]}" class="coordinate_left" name="post[more][dian][left]">
                                                    <input type="hidden" value="{$post[more][dian_name][top]}" class="coordinate_name_top" name="post[more][dian_name][top]">
                                                    <input type="hidden" value="{$post[more][dian_name][left]}" class="coordinate_name_left" name="post[more][dian_name][left]">
                                                    <input type="hidden" value="{$post[more][dian_name][width]}" class="coordinate_name_width" name="post[more][dian_name][width]">
                                                </div>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-smoffset-1 layui-col-sm10">
                        <input type="hidden" name="post[branch_id]" value="{$post.branch_id}">
                        <button type="submit" class="layui-btn layui-btn-normal js-ajax-submit" style="display:none;" id="js-ajax-submit">{:lang('SAVE')}</button>
                        <button type="button" class="layui-btn layui-btn-normal" onclick="CheckSubmit();" id="add-key">{:lang('SAVE')}</button>
                        <a class="btn btn-default" href="javascript:history.back(-1);">{:lang('BACK')}</a>
                    </div>
                </form>
            </div>
        </div>
        
    </div>
    <script type="text/javascript" src="__STATIC__/js/admin.js"></script>
    <script type="text/javascript" src="__STATIC__/js/modal.js"></script>
    <script type="text/javascript">
        //编辑器路径定义
        var editorURL = GV.WEB_ROOT;
    </script>
    <script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.js"></script>
</body>

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=38z4vZlVWK6oAdbrNuXnq1mB"></script>
<script type="text/javascript">
    $(function () {
        if( $('#content').length ){
            editorcontent = new baidu.editor.ui.Editor();
            editorcontent.render('content');
            try {
                editorcontent.sync();
            } catch (err) {
            }
        }

        if( $('#content2').length ){
            editorcontent2 = new baidu.editor.ui.Editor();
            editorcontent2.render('content2');
            try {
                editorcontent2.sync();
            } catch (err) {
            }
        }


        //移除缩略图
        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

        //追加扩展信息
        $('.addExtend').click(function(){
            var html = '';
                html += '<div class="extend">';
                    html += '<input class="layui-input" type="text" name="extend_name[]" placeholder="请输入名称">';
                    html += '<input class="layui-input" type="text" name="extend_val[]"  placeholder="请输入值">';
                    html += '<a href="javascript:;" class="removeExtend">[-]</a> </div>';
                html += '</div>';
            $(this).parent().before(html);
        });

        //移除扩展信息
        $('.col-md-9').on('click','.removeExtend',function(){
            $(this).parent().remove();
        });

    });

    //切换区域
    $('#region').change(function(){
        var branch_id = $(this).children('option:selected').val();
        if( branch_id != 0 ){
            var url = "{:url('AdminBranch/getBranchRegion')}";
            $.get(url,{'id':branch_id},function(result){
                $('.coordinate .bimg').attr('src',result.b_thumb);
            });
        }
    })
    

    //默认坐标点位置
    var dian_top  = $('.coordinate_top').val();
    var dian_left = $('.coordinate_left').val();
    if( dian_top && dian_left ){
        $(".coordinate .main").css({top:dian_top,left:dian_left});
        $(".coordinate .dian").show()
    }

    //默认坐标名位置
    var name_top   = $('.coordinate_name_top').val();
    var name_left  = $('.coordinate_name_left').val();
    var name_width = $('.coordinate_name_width').val();
    if( name_top && name_left && name_width ){
        $(".coordinate .name").css({top:name_top,left:name_left,width:name_width}).show();
    }

    //添加坐标名点击
    $('.add_coordinate_name').click(function(){
        var name  = $('.coordinate_name').val();
        if( name == '' ){
            artdialog_alert('请填写坐标名！');
            return false;
        }
        var width = (name.length)*14;
        $('.coordinate .name').html(name).css('width',width+'px').show();   //设置坐标名和宽度，并显示
        $('.coordinate_name_width').val(width+'px');                        //记录坐标名宽度
        if( $(".coordinate_top").val()=='' ){
            $(".coordinate_top").val($(".coordinate .main").css("top"));        //坐标点默认上偏移距离
            $(".coordinate_left").val($(".coordinate .main").css("left"));      //坐标点默认左偏移距离
        }
        $(".coordinate_name_top").val("-123%");      //坐标名默认上偏移距离
        $(".coordinate_name_left").val("47%");       //坐标名默认左偏移距离
        $('.coordinate .dian').show();               //显示坐标点
    })
    //添加坐标点击
    $('.add_coordinate').click(function(){
        $(".coordinate_top").val($(".coordinate .main").css("top"));    //坐标点默认上偏移距离
        $(".coordinate_left").val($(".coordinate .main").css("left"));  //坐标点默认左偏移距离
        $('.coordinate .dian').show();                                  //显示坐标点
    });

    //移除坐标点
    $('.remove_coordinate').click(function(){
        $(".coordinate_top").val('');   //清空坐标点上偏移距离
        $(".coordinate_left").val('');  //清空坐标点左偏移距离
        $('.coordinate .dian').hide();  //隐藏坐标点
        $(".coordinate .main").css({top:"5%",left:"3%"});    //重置坐标容器位置
    })
    
    //移除坐标名
    $('.remove_coordinate_name').click(function(){
        $(".coordinate_name_top").val('');  //清空坐标名上偏移距离
        $(".coordinate_name_left").val(''); //清空坐标名左偏移距离
        $('.coordinate .name').hide();      //隐藏坐标名
        $('.coordinate_name').val('');      //隐藏坐标名
    })

    //坐标点点击
    var _move=false;    //移动标记   
    var _x,_y;          //鼠标离控件左上角的相对位置
    $(".coordinate .dian").click(function(){  
        //alert("click");//点击（松开后触发）  
    }).mousedown(function(e){   
        if(!_move){  
            _move=true;   
            _x=e.pageX-parseInt($(".coordinate .main").css("left"));
            _y=e.pageY-parseInt($(".coordinate .main").css("top"));
            $(".coordinate .main").css('opacity',0.5)
        }else{  
            $(".coordinate .main").css('opacity',1)
            _move=false;  
        }
    });

    //坐标名点击
    var n_move=false;   //移动标记
    var n_x,n_y;        //鼠标离控件左上角的相对位置
    $(".coordinate .name").click(function(){  
        //alert("click");//点击（松开后触发）  
    }).mousedown(function(e){   
        if(!n_move){  
            n_move=true;   
            n_x=e.pageX-parseInt($(".coordinate .name").css("left"));
            n_y=e.pageY-parseInt($(".coordinate .name").css("top"));
            $(".coordinate .name").css('opacity',0.5)
        }else{  
            $(".coordinate .name").css('opacity',1)
            n_move=false;  
        }
    });

    //鼠标移动
    $(document).mousemove(function(e){   
        if(_move){   
            var x=e.pageX-_x;
            var y=e.pageY-_y;
            x = (x/1400*100)+'%';   //背景地图图片真实宽度
            y = (y/665*100)+'%';    //背景地图图片真实高度
            $(".coordinate .main").css('opacity',0.5);
            $(".coordinate .main").css({top:y,left:x});
            $(".coordinate_top").val(y);
            $(".coordinate_left").val(x);
        }

        if(n_move){   
            var x=e.pageX-n_x;
            var y=e.pageY-n_y;
            x = (x/21*100)+'%';
            y = (y/21*100)+'%';
            $(".coordinate .name").css('opacity',0.5);
            $(".coordinate .name").css({top:y,left:x});
            $(".coordinate_name_top").val(y);
            $(".coordinate_name_left").val(x);
        }
    })

    /***************************************** 百度地图相关 *****************************************/
        var map = new BMap.Map("container");
        var lng = '{$post.longitude}' != '' ? '{$post.longitude}' : '0';
        var lat = '{$post.latitude}' != '' ? '{$post.latitude}' : '0';

        if( lng!=0 && lat!=0 ){
            var point = new BMap.Point(lng,lat);

            map.centerAndZoom(point, 12);
            var marker = new BMap.Marker(point);// 创建标注
            map.addOverlay(marker);             // 将标注添加到地图中
            marker.enableDragging();    //可拖拽
            marker.addEventListener("dragend", function(e){
                document.getElementById("jingdu").value= e.point.lng;
                document.getElementById("weidu").value= e.point.lat;
            });
        }else {
            map.centerAndZoom("广州", 12);
        }
        map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用
        map.enableContinuousZoom();     //启用地图惯性拖拽，默认禁用
        map.addControl(new BMap.MapTypeControl()); //调用卫星地图
        map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
        map.addControl(new BMap.OverviewMapControl()); //添加默认缩略地图控件
        // 将标注添加到地图中
        var localSearch = new BMap.LocalSearch(map);
        localSearch.enableAutoViewport(); //允许自动调节窗体大小
        function searchByStationName(address) {
            var keyword = document.getElementById("text_").value;
            keyword = keyword=='' ? address : keyword ;
            if( keyword =='') return false;
            map.clearOverlays();//清空原来的标注
            localSearch.setSearchCompleteCallback(function (searchResult) {
                var poi = searchResult.getPoi(0);
                //document.getElementById("result_").value = poi.point.lng + "," + poi.point.lat;
                map.centerAndZoom(poi.point, 13);
                var marker = new BMap.Marker(new BMap.Point(poi.point.lng, poi.point.lat));  // 创建标注，为要查询的地址对应的经纬度
                document.getElementById("jingdu").value= poi.point.lng;
                document.getElementById("weidu").value= poi.point.lat;
                map.addOverlay(marker);
                marker.enableDragging();    //可拖拽
                marker.addEventListener("dragend", function(e){
                    document.getElementById("jingdu").value= e.point.lng;
                    document.getElementById("weidu").value= e.point.lat;
                });
            });
            localSearch.search(keyword);
        }
    /***************************************** 百度地图相关 *****************************************/
    function CheckSubmit(){
        var branch_name     = $("#branch_name").val();
        var keywords        = $("#keywords").val();
        var address         = $("#address").val();
        var excerpt         = $("#excerpt").val();
        var content         = editorcontent.getPlainTxt();
        var detail_content  = editorcontent2.getPlainTxt();
        var href = "{:url('goods/AdminGoods/replace')}";
        var data = {'data':'BRANCH_NAME:'+branch_name+',ADDRESS:'+address+',KEYWORDS:'+keywords+',ABSTRACT:'+excerpt+',LXWMDNR:'+content+',XINR:'+detail_content};
        $.ajax({
            url:  href,
            data: data,
            type: 'post',
            dataType: 'json',
            beforeSend:function(){
            },
            success: function (res) {
                if(res[0] !=1){
                    var str = '';
                    for(var p in res){
                        str = str+res[p];
                    }
                    str = str+'<p style="color:red;">是否确认替换？</p>';
                    $("#add-key").createModal({
                        background: "#000",//设定弹窗之后的覆盖层的颜色
                        width: "500px",//设定弹窗的宽度
                        height: "auto",//设定弹窗的高度
                        resizable: true,//设定弹窗是否可以拖动改变大小
                        move: false,//规定弹窗是否可以拖动
                        bgClose: false,//规定点击背景是否可以关闭
                        html: "<div class='modal-promot-mess'>提示信息</div>"
                                +"<div class='messge'>"+str+"</div>"
                                 +"<p class='insure-btn-con'><span class='sure-btn' onclick='tijiao()'>确定</span><span class='cancel-btn modal-close'>取消</span></p>",
                        
                    });
                }else{
                    $('#js-ajax-submit').click();
                }
            }
        });
    }
    function tijiao(){
        $('#js-ajax-submit').click();
    };
</script>


</html>
